package com.juyu.miliao.scheduler.message;

import com.alibaba.fastjson.JSONObject;
import com.juyu.miliao.common.constant.MakeFriendsMqKeyInfo;
import com.juyu.miliao.common.domain.dto.MakeFriendsMqUserVipTypeDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author xuanqicheng
 * @create 2019-09-11:45
 */
@Component
@Slf4j
public class MakeFriendsMessage {
    @Autowired
    private AmqpTemplate amqpTemplate;

    /**
     *
     * @param userId
     * @param isVip 1:vip,2:不是vip
     */
    public void sendUserVipType(long userId,int isVip) {
        MakeFriendsMqUserVipTypeDTO makeFriendsMqUserVipTypeDTO = new MakeFriendsMqUserVipTypeDTO();
        makeFriendsMqUserVipTypeDTO.setUserId(userId);
        makeFriendsMqUserVipTypeDTO.setIsVip(isVip);
        amqpTemplate.convertAndSend(MakeFriendsMqKeyInfo.MAKE_FRIENDS_EXCHANGE,
                MakeFriendsMqKeyInfo.MAKE_FRIENDS_USER_VIP_TYPE_ROUTING,
                JSONObject.toJSONString(makeFriendsMqUserVipTypeDTO));
    }

}